import java.io.*;
import java.util.Scanner;

public class Demo68 {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入要复制 的源文件");
        String srcOath = scanner.next();
        System.out.println("请输入要复制的目标文件");
        String destPath = scanner.next();
        File srcFile = new File(destPath);
        if(srcFile.isFile()){
            return;
        }
        File destFile = new File(destPath);
        if(destFile.getParentFile().isDirectory()){
            return;
        }
        try(InputStream inputStream = new FileInputStream(srcFile);OutputStream outputStream = new FileOutputStream(destFile)){
            while(true){
                byte[] buffer = new byte[1024];
                int n = inputStream.read(buffer);
                if(n==-1){
                    break;
                }
                outputStream.write(buffer,0,n);
            }
        }
    }
}
